package com.chensf.studydemo.guide.design

import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import com.chensf.studydemo.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.android.synthetic.main.activity_bottom_sheet_demo.*

class BottomSheetDemo : AppCompatActivity(){
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bottom_sheet_demo)
        sheetDialog.setOnClickListener {
            showBottomSheetDialog()
        }
    }

    private fun showBottomSheetDialog() {
        val bottomDialog = BottomSheetDialog(this)
        val view = layoutInflater.inflate(R.layout.view_bottom_sheet_dialog,null)
        bottomDialog.setContentView(view)
        kotlin.runCatching {
            (view.parent as ViewGroup).setBackgroundResource(android.R.color.transparent)
        }
        bottomDialog.show()
    }
}